package com.practice.pagehelper.controller;

import com.practice.pagehelper.dto.req.BasePageReqDto;
import com.practice.pagehelper.entity.PersonOrgRelEntity;
import com.practice.pagehelper.service.PersonOrgRelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * @Description : 人员组织控制层
 * @Author : xxx
 * @Version : V1.0.0
 * @Date : 2021/9/18 15:38
 */
@RequestMapping(value = "/test/pageHelper")
public class PersonOrgController {

    @Autowired
    private PersonOrgRelService personOrgRelService;

    @GetMapping(value = "/query/person")
    public String queryPerson() {
        PersonOrgRelEntity query = new PersonOrgRelEntity();
        PersonOrgRelEntity result = personOrgRelService.queryPerson(query);
        return result.toString();
    }


    @GetMapping(value = "/query/personsPage")
    public String personsPage() {
        BasePageReqDto query = new BasePageReqDto();
        List<PersonOrgRelEntity> personOrgRelEntities = personOrgRelService.queryPagePerson(query);
        Optional.ofNullable(personOrgRelEntities).ifPresent(relEntityList -> {
            for (PersonOrgRelEntity relEntity : relEntityList) {
            }
        });
        return "query success";
    }

}
